package com.ruoyi.pc.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.pc.domain.LbUserWechat;
import com.ruoyi.pc.service.ILbUserWechatService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 系统用户和微信用户关联关系Controller
 * 
 * @author ruoyi
 * @date 2020-06-21
 */
@RestController
@RequestMapping("/lbuserwechat")
public class LbUserWechatController extends BaseController
{
    @Autowired
    private ILbUserWechatService lbUserWechatService;

    /**
     * 查询系统用户和微信用户关联关系列表
     */
    @PreAuthorize("@ss.hasPermi('business:lbuserwechat:list')")
    @GetMapping("/list")
    public TableDataInfo list(LbUserWechat lbUserWechat)
    {
        startPage();
        List<LbUserWechat> list = lbUserWechatService.selectLbUserWechatList(lbUserWechat);
        return getDataTable(list);
    }

    /**
     * 导出系统用户和微信用户关联关系列表
     */
    @PreAuthorize("@ss.hasPermi('business:lbuserwechat:export')")
    @Log(title = "系统用户和微信用户关联关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LbUserWechat lbUserWechat) throws IOException
    {
        List<LbUserWechat> list = lbUserWechatService.selectLbUserWechatList(lbUserWechat);
        ExcelUtil<LbUserWechat> util = new ExcelUtil<LbUserWechat>(LbUserWechat.class);
        util.exportExcel(response, list, "lbuserwechat");
    }

    /**
     * 获取系统用户和微信用户关联关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:lbuserwechat:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(lbUserWechatService.selectLbUserWechatById(id));
    }

    /**
     * 新增系统用户和微信用户关联关系
     */
    @PreAuthorize("@ss.hasPermi('business:lbuserwechat:add')")
    @Log(title = "系统用户和微信用户关联关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LbUserWechat lbUserWechat)
    {
        return toAjax(lbUserWechatService.insertLbUserWechat(lbUserWechat));
    }

    /**
     * 修改系统用户和微信用户关联关系
     */
    @PreAuthorize("@ss.hasPermi('business:lbuserwechat:edit')")
    @Log(title = "系统用户和微信用户关联关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LbUserWechat lbUserWechat)
    {
        return toAjax(lbUserWechatService.updateLbUserWechat(lbUserWechat));
    }

    /**
     * 删除系统用户和微信用户关联关系
     */
    @PreAuthorize("@ss.hasPermi('business:lbuserwechat:remove')")
    @Log(title = "系统用户和微信用户关联关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lbUserWechatService.deleteLbUserWechatByIds(ids));
    }
}
